'use strict'

var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault')

Object.defineProperty(exports, '__esModule', {
  value: true
})
exports.composeRef = composeRef
exports.default = void 0
exports.fillRef = fillRef

var _typeof2 = _interopRequireDefault(require('@babel/runtime/helpers/typeof'))

function createRef() {
  var func = function func(node) {
    func.current = node
  }

  return func
}

function fillRef(ref, node) {
  if (typeof ref === 'function') {
    ref(node)
  } else if ((0, _typeof2.default)(ref) === 'object' && ref && 'current' in ref) {
    ref.current = node
  }
}
/**
 * Merge refs into one ref function to support ref passing.
 */

function composeRef() {
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
    refs[_key] = arguments[_key]
  }

  return function(node) {
    refs.forEach(function(ref) {
      fillRef(ref, node)
    })
  }
}

var _default = createRef
exports.default = _default
